<?php
    global $mikron;
    $mikron->Tools->SiteMenu->setCurrentPage('/');
?>

<table class="cabinet_table" border="0" width="100%">
<tbody>
<tr>
    <td>
        {{slidewindow caption="Основное" showtext="Редактировать" hidetext="Скрыть" comment=""}}
        <?php 
            $f1 = new html_form('performer_info');
            $user = $mikron->Users->CurrentUser()->user;
            if($f1->pageindex == 2)
            {
                $name = $mikron->Tools->GetParam($f1->formdata, 'name', null);
                $firmName = $mikron->Tools->GetParam($f1->formdata, 'firmname', null);
                $country = (int)$mikron->Tools->GetParam($f1->formdata, 'country', null);
                $city = (int)$mikron->Tools->GetParam($f1->formdata, 'city', null);
                $user->firmname->value = $firmName;
                $user->country->value = $country;
                $user->city->value = $city;
                $user->Save();
                $f1->pageindex = 1;
            }
            $country_id = null;
            $city_id = null;
            if(is_object($user->country->value))
            {
                $country_id = $user->country->value->id;
            }
            if(is_object($user->city->value))
            {
                $city_id = $user->city->value->id;
            }
            $tab1 = new html_table(1, 'microwindow', null, 0, 2);
            $tab1->newcol('Название организации и ФИО Заказчика:', true, null, null, 'caption');
            $tab1->newcol();
                $f1->addInput(1, 'firmname', null, 64, null, false, $user->firmname->value);
            $tab1->newcol('Регион Заказчика:', true, null, null, 'caption');
            $tab1->newcol();
                $items1 = $mikron->Queries->Query('COUNTRY');
                $f1->addSelectControlFromEntity(1, 'country', null, $items1, $country_id, Array('fieldname'=>'city', 'sourcefile'=> '/action/tosmr/getcities/?country={1}&format=options'), 'Укажите страну');
            $tab1->newcol();
                $items2 = Array();
                $items2 = $mikron->Queries->Query('CITY', null, new Criterion('country', $country_id));
                $f1->addSelectControlFromEntity(1, 'city', null, $items2, $city_id, null, 'Укажите город');
            $tab1->newcol(null, false, 'right');
                $f1->addSubmit('save', 'Сохранить');                
            $tab1->end();
            $f1->end();
        ?>

        <!--
            {{userform entityname=T_USER
                id=<?php echo $mikron->Users->CurrentUser()->id(); ?>
                hide_labels=1
                cellspacing=4
                cellpadding=0
                inputsize=64
                submit_caption=Сохранить
                        htmlform='<table
                            id="%mikron_editor_table_id%"
                            style="%mikron_editor_table_style%"
                            border="0"
                            cellspacing="%mikron_editor_table_cellspacing%"
                            cellpadding="%mikron_editor_table_cellpadding%">
                            <tr><tr><td colspan="2">Название организации и ФИО Заказчика:</td></tr>
                            <tr><tr><td colspan="2">%firmname%</td></tr>
                            <tr><tr><td colspan="2">Регион Заказчика:</td></tr>
                            <tr><tr><td colspan="2">%country%</td></tr>
                            <tr><tr><td colspan="2">%city%</td></tr>
                            <tr><td colspan="2">%mikron_editor_form_submit_button%</td></tr>
                            </table>'
            
            }}
        -->
        {{/slidewindow}}

        {{slidewindow caption="О Заказчике" showtext="Редактировать" hidetext="Скрыть" comment=""}}
            {{userform entityname=T_USER
                id=<?php echo $mikron->Users->CurrentUser()->id(); ?>
                hide_labels=1
                cellspacing=4
                cellpadding=0
                inputsize=64
                submit_caption=Сохранить
                        htmlform='<table
                            id="%mikron_editor_table_id%"
                            style="%mikron_editor_table_style%"
                            border="0"
                            cellspacing="%mikron_editor_table_cellspacing%"
                            cellpadding="%mikron_editor_table_cellpadding%">
                            <tr><td colspan="2">%information%</td></tr>
                            <tr><td colspan="2">%mikron_editor_form_submit_button%</td></tr>
                            </table>'
            
            }}
        {{/slidewindow}}
        
        {{slidewindow caption="Контакты" showtext="Редактировать" hidetext="Скрыть" comment=""}}
            {{userform entityname=T_USER
                id=<?php echo $mikron->Users->CurrentUser()->id(); ?>
                hide_labels=0
                cellspacing=4
                cellpadding=0
                inputsize=64
                submit_caption=Сохранить
                        htmlform='<table
                            id="%mikron_editor_table_id%"
                            style="%mikron_editor_table_style%"
                            border="0"
                            cellspacing="%mikron_editor_table_cellspacing%"
                            cellpadding="%mikron_editor_table_cellpadding%">
                            <tr><td colspan="2">%phone%</td></tr>
                            <tr><td colspan="2">%email%</td></tr>
                            <tr><td colspan="2">%mikron_editor_form_submit_button%</td></tr>
                            </table>'
            
            }}
        {{/slidewindow}}

        {{slidewindow caption="Куратор" showtext="Редактировать" hidetext="Скрыть" comment=""}}
            {{userform entityname=T_USER
                id=<?php echo $mikron->Users->CurrentUser()->id(); ?>
                hide_labels=1
                cellspacing=4
                cellpadding=0
                inputsize=64
                submit_caption=Сохранить
                        htmlform='<table
                            id="%mikron_editor_table_id%"
                            style="%mikron_editor_table_style%"
                            border="0"
                            cellspacing="%mikron_editor_table_cellspacing%"
                            cellpadding="%mikron_editor_table_cellpadding%">
                            <tr><td>ФИО:</td><td colspan="2">%curator_fio%</td></tr>
                            <tr><td>Должность:</td><td colspan="2">%curator_post%</td></tr>
                            <tr><td>Телефон:</td><td colspan="2">%curator_phone%</td></tr>
                            <tr><td>E-mail:</td><td colspan="2">%curator_email%</td></tr>
                            <tr><td colspan="2">%mikron_editor_form_submit_button%</td></tr>
                            </table>'
            
            }}
        {{/slidewindow}}

    </td>
</tr>
</tbody>
</table>
